package com.training.bt.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@TableName("tb_private_message")
public class PrivateMessage {
    @TableId(type = IdType.AUTO)
    private  Long messageId;
    private  Long senderId;
    private  Long receiverId;
    private String messageContent;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime sendTime;

    private Boolean isRead = false;

    // 发送时自动设置时间
    public void onCreate() {
        if (sendTime == null) {
            sendTime = LocalDateTime.now();
        }
    }
}